package com.reminis.exceldemo.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.math.BigDecimal;

/**
 * DTO for receiving data pasted from text input.
 * Fields are kept as String initially for flexibility during parsing/validation,
 * but conversion to appropriate types (Double/BigDecimal) will happen in the service layer.
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TextInputDataDto {

    private String zhonglei; // 中类
    private String quantity; // 数量 (String to handle potential parsing issues initially)
    private String amount;   // 金额 (String to handle potential parsing issues initially)

    // Optional: Add methods for safe conversion if needed here,
    // or perform conversion in the service layer.
    public Double getQuantityAsDouble() {
        try {
            return Double.parseDouble(this.quantity);
        } catch (NumberFormatException | NullPointerException e) {
            return null; // Or throw a specific exception
        }
    }

    public BigDecimal getAmountAsBigDecimal() {
        try {
            // Use BigDecimal for monetary values
            return new BigDecimal(this.amount);
        } catch (NumberFormatException | NullPointerException e) {
            return null; // Or throw a specific exception
        }
    }
} 